package com.jt.mapper;

import com.jt.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {
    List<User> findAll();

    //注解和映射文件只能二选一
    @Select("select * from demo_user where id = #{id}")
    User findUserById(Integer id);

    @Select("select * from demo_user where age=#{age} and sex=#{sex}")
    List<User> findUserByAS(User user);

    @Update("update demo_user set name=#{name},age=#{age}," +
            "sex =#{sex} where id=#{id}")
    void updateById(User user);

    @Select("select * from demo_user where name like \"%\"#{name}\"%\"")
    List<User> findUserByName(String name);


    List<User> findUserByIds(Integer[] ids);

    @Insert("insert into demo_user(name,age,sex) values(#{name},#{age},#{sex})")
    public void saveUser(User user);



}
